package com.yiren.backstage.currency.bean;

import com.yiren.backstage.currency.enums.CarStateValueEnum;

/**
 * Time:2021/11/19 15:56
 * Author:xiaozan
 * Description:车辆状态对象
 */
public class CarStateBean {

    private static final CarStateBean single = new CarStateBean();

    public static CarStateBean getInstance() {
        return single;
    }

    /************************基本信号****************************************/
    /*** 绕车：左前 */
    private CarStateValueEnum carHeadLeft = CarStateValueEnum.NO_DETECT;

    /***绕车：右后 */
    private CarStateValueEnum carTailRight = CarStateValueEnum.NO_DETECT;

    /*** 绕车：右前 */
    private CarStateValueEnum carHeadRight = CarStateValueEnum.NO_DETECT;

    /*** 绕车：左后 */
    private CarStateValueEnum carTailLeft = CarStateValueEnum.NO_DETECT;

    /*** 车门 */
    private CarStateValueEnum carDoor = CarStateValueEnum.NO_DETECT;

    /*** 指纹仪 */
    private CarStateValueEnum fingerprint = CarStateValueEnum.NO_DETECT;

    /*** 反光镜. */
    private CarStateValueEnum reflectorMirror = CarStateValueEnum.NO_DETECT;

    /*** 后视镜. */
    private CarStateValueEnum rearviewMirror = CarStateValueEnum.NO_DETECT;

    /*** 座椅. */
    private CarStateValueEnum seat = CarStateValueEnum.NO_DETECT;

    /*** 行车灯. */
    private CarStateValueEnum drivingLamp = CarStateValueEnum.NO_DETECT;

    /*** 警示灯. */
    private CarStateValueEnum cautionLight = CarStateValueEnum.NO_DETECT;

    /*** 远光. */
    private CarStateValueEnum distanceLight = CarStateValueEnum.NO_DETECT;

    /*** 近光 */
    private CarStateValueEnum passingLight = CarStateValueEnum.NO_DETECT;

    /*** 左转灯 */
    private CarStateValueEnum leftLight = CarStateValueEnum.NO_DETECT;

    /*** 右转灯 */
    private CarStateValueEnum rightLight = CarStateValueEnum.NO_DETECT;

    /*** 雾灯. */
    private CarStateValueEnum foglight = CarStateValueEnum.NO_DETECT;

    /*** 安全带. */
    private CarStateValueEnum safetyBelt = CarStateValueEnum.NO_DETECT;

    /*** 手刹. */
    private CarStateValueEnum parkingBrake = CarStateValueEnum.NO_DETECT;

    /*** 脚刹. */
    private CarStateValueEnum footBrake = CarStateValueEnum.NO_DETECT;

    /*** 方向盘角度 */
    private float steerAngel = 0;

    /*** 离合. */
    private CarStateValueEnum separationReunion = CarStateValueEnum.NO_DETECT;

    /*** 喇叭. */
    private CarStateValueEnum horn = CarStateValueEnum.NO_DETECT;

    /*** 钥匙 */
    private CarStateValueEnum carKey = CarStateValueEnum.KEY_LOCK_OFF;

    /*** 雨刮器*/
    private CarStateValueEnum rainWipper = CarStateValueEnum.CLOSE;

    /*** 档位-默认空档.*/
    private CarStateValueEnum gear = CarStateValueEnum.NEUTRAL_GEAR;

    /*** 转速. */
    private float rotateSpeed = 0;

    /*** 转速脉冲值 */
    private float rotateSpeedPulse;

    /*** 车速. */
    private double speed = 0;

    /*** 俯仰角 */
    private float pitchAngle;

    /*** 车速脉冲值 */
    private float speedPulse;

    /*** 档位比. */
    private double gearLevel = 0;

    /*** 累计里程（毫米） */
    private float totalMileage = 0;

    /*** OBD车型 */
    private String obdCarModel;

    /*** 车辆急打方向检测 */
    private CarStateValueEnum hurryOfDirection = CarStateValueEnum.NO_DETECT;

    /*** 将车辆停在人行横道、停止线、网状线、禁停区域内等禁止停车区域 */
    private CarStateValueEnum carTopProhibitRegion = CarStateValueEnum.NO_DETECT;

    /*** 高精度车辆触发人行横道线 */
    private CarStateValueEnum carTouchProhibitRegion = CarStateValueEnum.NO_DETECT;

    /*** 压道路行驶箭头 */
    private CarStateValueEnum carPressXsjt = CarStateValueEnum.NO_DETECT;

    /*** 连续变更两条车道 */
    private CarStateValueEnum changeTwoLanes = CarStateValueEnum.NO_DETECT;

    /*** 压中心圈 */
    private CarStateValueEnum pressZxq = CarStateValueEnum.NO_DETECT;

    /*** 中心圈左侧转弯检测 */
    private CarStateValueEnum zxqRightTurnCircle = CarStateValueEnum.NO_DETECT;

    /*** 人行横道线上掉头检测 */
    private CarStateValueEnum rxhdxTurnRound = CarStateValueEnum.NO_DETECT;

    /*** 车辆通过停止线检测 */
    private CarStateValueEnum tzxCarPass = CarStateValueEnum.NO_DETECT;

    /*** 车辆通过人行横道线检测 */
    private CarStateValueEnum rxhdxCarPass = CarStateValueEnum.NO_DETECT;

    /*** 压实线 */
    private CarStateValueEnum pressSLine = CarStateValueEnum.NO_DETECT;

    /*** 压虚线 */
    private CarStateValueEnum pressXLine = CarStateValueEnum.NO_DETECT;

    /*** 压起步靠边实线 */
    private CarStateValueEnum pressQbkbFullLine = CarStateValueEnum.NO_DETECT;

    /*** 左变道 */
    private CarStateValueEnum carLeftChangeLane = CarStateValueEnum.NO_DETECT;

    /*** 右变道 */
    private CarStateValueEnum carRightChangeLane = CarStateValueEnum.NO_DETECT;

    /*** 车辆与刹车区域相交检测 */
    private CarStateValueEnum carIntersectScqy = CarStateValueEnum.NO_DETECT;

    /*** 左前轮到最近车道的距离 */
    private int leftFrontDistance = 9999;

    /*** 左后轮到最近车道的距离 */
    private int leftBackDistance = 9999;

    /*** 右前轮到最近车道的距离 */
    private int rightFrontDistance = 9999;

    /*** 右后轮到最近车道的距离 */
    private int rightBackDistance = 9999;

    /*** 后溜距离. */
    private int backSkateDistance = 0;

    /*** 陀螺仪实时角度 */
    private float nsbsAngleDiff;

    /*** 行驶车道 */
    private int travelVehicleLane;

    public CarStateValueEnum getCarHeadLeft() {
        return carHeadLeft;
    }

    public void setCarHeadLeft(CarStateValueEnum carHeadLeft) {
        this.carHeadLeft = carHeadLeft;
    }

    public CarStateValueEnum getCarTailRight() {
        return carTailRight;
    }

    public void setCarTailRight(CarStateValueEnum carTailRight) {
        this.carTailRight = carTailRight;
    }

    public CarStateValueEnum getCarHeadRight() {
        return carHeadRight;
    }

    public void setCarHeadRight(CarStateValueEnum carHeadRight) {
        this.carHeadRight = carHeadRight;
    }

    public CarStateValueEnum getCarTailLeft() {
        return carTailLeft;
    }

    public void setCarTailLeft(CarStateValueEnum carTailLeft) {
        this.carTailLeft = carTailLeft;
    }

    public CarStateValueEnum getCarDoor() {
        return carDoor;
    }

    public void setCarDoor(CarStateValueEnum carDoor) {
        this.carDoor = carDoor;
    }

    public CarStateValueEnum getFingerprint() {
        return fingerprint;
    }

    public void setFingerprint(CarStateValueEnum fingerprint) {
        this.fingerprint = fingerprint;
    }

    public CarStateValueEnum getReflectorMirror() {
        return reflectorMirror;
    }

    public void setReflectorMirror(CarStateValueEnum reflectorMirror) {
        this.reflectorMirror = reflectorMirror;
    }

    public CarStateValueEnum getRearviewMirror() {
        return rearviewMirror;
    }

    public void setRearviewMirror(CarStateValueEnum rearviewMirror) {
        this.rearviewMirror = rearviewMirror;
    }

    public CarStateValueEnum getSeat() {
        return seat;
    }

    public void setSeat(CarStateValueEnum seat) {
        this.seat = seat;
    }

    public CarStateValueEnum getDrivingLamp() {
        return drivingLamp;
    }

    public void setDrivingLamp(CarStateValueEnum drivingLamp) {
        this.drivingLamp = drivingLamp;
    }

    public CarStateValueEnum getCautionLight() {
        return cautionLight;
    }

    public void setCautionLight(CarStateValueEnum cautionLight) {
        this.cautionLight = cautionLight;
    }

    public CarStateValueEnum getDistanceLight() {
        return distanceLight;
    }

    public void setDistanceLight(CarStateValueEnum distanceLight) {
        this.distanceLight = distanceLight;
    }

    public CarStateValueEnum getPassingLight() {
        return passingLight;
    }

    public void setPassingLight(CarStateValueEnum passingLight) {
        this.passingLight = passingLight;
    }

    public CarStateValueEnum getLeftLight() {
        return leftLight;
    }

    public void setLeftLight(CarStateValueEnum leftLight) {
        this.leftLight = leftLight;
    }

    public CarStateValueEnum getRightLight() {
        return rightLight;
    }

    public void setRightLight(CarStateValueEnum rightLight) {
        this.rightLight = rightLight;
    }

    public CarStateValueEnum getFoglight() {
        return foglight;
    }

    public void setFoglight(CarStateValueEnum foglight) {
        this.foglight = foglight;
    }

    public CarStateValueEnum getSafetyBelt() {
        return safetyBelt;
    }

    public void setSafetyBelt(CarStateValueEnum safetyBelt) {
        this.safetyBelt = safetyBelt;
    }

    public CarStateValueEnum getParkingBrake() {
        return parkingBrake;
    }

    public void setParkingBrake(CarStateValueEnum parkingBrake) {
        this.parkingBrake = parkingBrake;
    }

    public CarStateValueEnum getFootBrake() {
        return footBrake;
    }

    public void setFootBrake(CarStateValueEnum footBrake) {
        this.footBrake = footBrake;
    }

    public float getSteerAngel() {
        return steerAngel;
    }

    public void setSteerAngel(float steerAngel) {
        this.steerAngel = steerAngel;
    }

    public CarStateValueEnum getSeparationReunion() {
        return separationReunion;
    }

    public void setSeparationReunion(CarStateValueEnum separationReunion) {
        this.separationReunion = separationReunion;
    }

    public CarStateValueEnum getHorn() {
        return horn;
    }

    public void setHorn(CarStateValueEnum horn) {
        this.horn = horn;
    }

    public CarStateValueEnum getCarKey() {
        return carKey;
    }

    public void setCarKey(CarStateValueEnum carKey) {
        this.carKey = carKey;
    }

    public CarStateValueEnum getRainWipper() {
        return rainWipper;
    }

    public void setRainWipper(CarStateValueEnum rainWipper) {
        this.rainWipper = rainWipper;
    }

    public CarStateValueEnum getGear() {
        return gear;
    }

    public void setGear(CarStateValueEnum gear) {
        this.gear = gear;
    }

    public float getRotateSpeed() {
        return rotateSpeed;
    }

    public void setRotateSpeed(float rotateSpeed) {
        this.rotateSpeed = rotateSpeed;
    }

    public float getPitchAngle() {
        return pitchAngle;
    }

    public void setPitchAngle(float pitchAngle) {
        this.pitchAngle = pitchAngle;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
        countMileageForObd(speed);
    }

    private long lastTime = 0;

    /**
     * 计算里程 计算里程
     *
     * @param speed
     */
    private void countMileageForObd(double speed) {
        if (lastTime == 0) {
            lastTime = System.currentTimeMillis();
        }
        long currentTime = System.currentTimeMillis();
        float currentCostTime = (float) ((currentTime - lastTime) / 1000.0);
        if (currentCostTime > 0 && currentCostTime < 5) {
            //解决由于开机时间与网络时间不一样的时候，中间突然连接到网络，导致里程突增的现象
            float totalMileage = getTotalMileage();
            totalMileage += ((speed / 3.6) * currentCostTime) * 1000.0;
            setTotalMileage(totalMileage);
        }
        lastTime = currentTime;
    }

    public double getGearLevel() {
        return gearLevel;
    }

    public void setGearLevel(double gearLevel) {
        this.gearLevel = gearLevel;
    }

    public float getTotalMileage() {
        return totalMileage;
    }

    public void setTotalMileage(float totalMileage) {
        this.totalMileage = totalMileage;
    }

    public CarStateValueEnum getCarTopProhibitRegion() {
        return carTopProhibitRegion;
    }

    public void setCarTopProhibitRegion(CarStateValueEnum carTopProhibitRegion) {
        this.carTopProhibitRegion = carTopProhibitRegion;
    }

    public CarStateValueEnum getCarTouchProhibitRegion() {
        return carTouchProhibitRegion;
    }

    public void setCarTouchProhibitRegion(CarStateValueEnum carTouchProhibitRegion) {
        this.carTouchProhibitRegion = carTouchProhibitRegion;
    }

    public CarStateValueEnum getCarPressXsjt() {
        return carPressXsjt;
    }

    public void setCarPressXsjt(CarStateValueEnum carPressXsjt) {
        this.carPressXsjt = carPressXsjt;
    }

    public CarStateValueEnum getChangeTwoLanes() {
        return changeTwoLanes;
    }

    public void setChangeTwoLanes(CarStateValueEnum changeTwoLanes) {
        this.changeTwoLanes = changeTwoLanes;
    }

    public CarStateValueEnum getPressZxq() {
        return pressZxq;
    }

    public void setPressZxq(CarStateValueEnum pressZxq) {
        this.pressZxq = pressZxq;
    }

    public CarStateValueEnum getZxqRightTurnCircle() {
        return zxqRightTurnCircle;
    }

    public void setZxqRightTurnCircle(CarStateValueEnum zxqRightTurnCircle) {
        this.zxqRightTurnCircle = zxqRightTurnCircle;
    }

    public CarStateValueEnum getRxhdxTurnRound() {
        return rxhdxTurnRound;
    }

    public void setRxhdxTurnRound(CarStateValueEnum rxhdxTurnRound) {
        this.rxhdxTurnRound = rxhdxTurnRound;
    }

    public CarStateValueEnum getTzxCarPass() {
        return tzxCarPass;
    }

    public void setTzxCarPass(CarStateValueEnum tzxCarPass) {
        this.tzxCarPass = tzxCarPass;
    }

    public CarStateValueEnum getRxhdxCarPass() {
        return rxhdxCarPass;
    }

    public void setRxhdxCarPass(CarStateValueEnum rxhdxCarPass) {
        this.rxhdxCarPass = rxhdxCarPass;
    }

    public CarStateValueEnum getHurryOfDirection() {
        return hurryOfDirection;
    }

    public void setHurryOfDirection(CarStateValueEnum hurryOfDirection) {
        this.hurryOfDirection = hurryOfDirection;
    }

    public CarStateValueEnum getPressQbkbFullLine() {
        return pressQbkbFullLine;
    }

    public void setPressQbkbFullLine(CarStateValueEnum pressQbkbFullLine) {
        this.pressQbkbFullLine = pressQbkbFullLine;
    }

    public CarStateValueEnum getPressSLine() {
        return pressSLine;
    }

    public void setPressSLine(CarStateValueEnum pressSLine) {
        this.pressSLine = pressSLine;
    }

    public CarStateValueEnum getPressXLine() {
        return pressXLine;
    }

    public void setPressXLine(CarStateValueEnum pressXLine) {
        this.pressXLine = pressXLine;
    }

    public CarStateValueEnum getCarLeftChangeLane() {
        return carLeftChangeLane;
    }

    public void setCarLeftChangeLane(CarStateValueEnum carLeftChangeLane) {
        this.carLeftChangeLane = carLeftChangeLane;
    }

    public CarStateValueEnum getCarRightChangeLane() {
        return carRightChangeLane;
    }

    public void setCarRightChangeLane(CarStateValueEnum carRightChangeLane) {
        this.carRightChangeLane = carRightChangeLane;
    }

    public CarStateValueEnum getCarIntersectScqy() {
        return carIntersectScqy;
    }

    public void setCarIntersectScqy(CarStateValueEnum carIntersectScqy) {
        this.carIntersectScqy = carIntersectScqy;
    }

    public int getBackSkateDistance() {
        return backSkateDistance;
    }

    public void setBackSkateDistance(int backSkateDistance) {
        this.backSkateDistance = backSkateDistance;
    }

    public int getLeftFrontDistance() {
        return leftFrontDistance;
    }

    public void setLeftFrontDistance(int leftFrontDistance) {
        this.leftFrontDistance = leftFrontDistance;
    }

    public int getLeftBackDistance() {
        return leftBackDistance;
    }

    public void setLeftBackDistance(int leftBackDistance) {
        this.leftBackDistance = leftBackDistance;
    }

    public int getRightFrontDistance() {
        return rightFrontDistance;
    }

    public void setRightFrontDistance(int rightFrontDistance) {
        this.rightFrontDistance = rightFrontDistance;
    }

    public int getRightBackDistance() {
        return rightBackDistance;
    }

    public void setRightBackDistance(int rightBackDistance) {
        this.rightBackDistance = rightBackDistance;
    }

    public float getNsbsAngleDiff() {
        return nsbsAngleDiff;
    }

    public void setNsbsAngleDiff(float nsbsAngleDiff) {
        this.nsbsAngleDiff = nsbsAngleDiff;
    }

    public int getTravelVehicleLane() {
        return travelVehicleLane;
    }

    public void setTravelVehicleLane(int travelVehicleLane) {
        this.travelVehicleLane = travelVehicleLane;
    }

    public String getObdCarModel() {
        return obdCarModel;
    }

    public void setObdCarModel(String obdCarModel) {
        this.obdCarModel = obdCarModel;
    }

    public void setRotateSpeedPulse(float rotateSpeedPulse) {
        this.rotateSpeedPulse = rotateSpeedPulse;
    }

    public void setSpeedPulse(float speedPulse) {
        this.speedPulse = speedPulse;
    }

    public float getRotateSpeedPulse() {
        return rotateSpeedPulse;
    }

    public float getSpeedPulse() {
        return speedPulse;
    }
}